<%--
    Document   : useredit
    Created on : 2012-3-16, 17:56:24
    Author     : xiaoxiao
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib  prefix="s"  uri="/struts-tags"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>用户编辑</title>
        <link href="css/global.css" rel="stylesheet" type="text/css">
        <link href="css/form.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/jquery.validate.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#signup').validate({
                    rules: {
                        username: {
                            required: true,
                            rangelength:[4,16]
                        },
                        email: {
                            required: true,
                            email: true
                        },
                        nowpassword: {equalTo:'#prepassword'},
                        password: {
                            required: true,
                            rangelength:[5,16]
                        },
                        confirm_password: {equalTo:'#password'},

                        spam: "required"
                    }, //end rules
                    messages: {
                        username: {
                            required: '请输入用户名',
                            rangelength: '用户名在 4 到 16 位之间'
                        },
                        email: {
                            required: "请输入邮箱地址",
                            email: "不是有效的邮箱地址"
                        },                     
                        password: {
                            required: '请输入密码',
                            rangelength: '密码在 5 到 16 位之间'
                        },
                        nowpassword:{
                            equalTo: '与原密码不符'
                        },
                        confirm_password: {
                            equalTo: '2次密码不一致'
                        }
                    },
                    errorPlacement: function(error, element) {
                        if ( element.is(":radio") || element.is(":checkbox")) {
                            error.appendTo( element.parent());
                        } else {
                            error.insertAfter(element);
                        }

                    }

                }); // end validate
            }); // end ready()
        </script>
    </head>
    <body>
        <s:if test="%{#session.islogin}">
            <div id="contentWrap">
                <div id="main">
                    <h2>修改个人信息</h2>
                    <s:form action="infochange" method="post" name="signup" id="signup">
                        <s:hidden name="userid" value="%{#session.userid}"></s:hidden>
                        <s:hidden name="prepassword" value="%{#session.password}" id="prepassword"></s:hidden>
                        <div>
                            <label  class="label">用户名</label>
                            <s:textfield name="username" label="用户名" value="%{#session.username}" readonly="true"></s:textfield>
                        </div>
                        <div>
                            <label  class="label">原密码</label>
                            <s:password name="nowpassword" id="nowpassword"></s:password>
                        </div>
                        <div>
                            <label class="label">新密码</label>
                            <s:password name="password"  id="password"></s:password>
                        </div>
                        <div>
                            <label class="label">确认新密码</label>
                            <s:password name="confirm_password" id="confirm_password"></s:password>
                        </div>
                        <div>
                            <label  class="label">邮箱</label>
                            <s:textfield name="email" label="邮箱" value="%{#session.email}" id="email"></s:textfield>
                        </div>
                        <div>
                            <s:submit value="修改" id="update"></s:submit>
                        </div>
                    </s:form>
                </div>
            </div>
            </s:if>
        <s:else>
            <%
            response.sendRedirect("login.jsp");
            %>
        </s:else>
        </body>
    </html>
